package startup

import (
	bean "shop-bean/model"
	"shop-common/library/env"
	"shop-common/library/variables"
	cron "shop-scheduler/model"
	sys "shop-sys/model"
)

func Migrate() error {
	var err error
	if variables.GormDB() != nil && env.IsDevMode() {
		err = variables.GormDB().AutoMigrate(
			&sys.SysUser{},
			&sys.SysUserRole{},
			&sys.SysRoleMenu{},
			&sys.SysMenu{},
			&sys.SysXhr{},
			&sys.SysRole{},
			&sys.SysLog{},

			&bean.File{},
			&bean.Attachment{},
			&bean.Area{},
			//城市数据
			&bean.SettingCity{},
			&bean.User{},

			//todo 做到移动端时候要对这把 SystemStore 替换成 PickAddr
			&bean.PickAddr{},
			&bean.SystemStore{},

			&bean.Notice{},

			&bean.ProdTag{},
			&bean.ProdTagReference{},

			&bean.AttachFile{},
			&bean.Product{},
			&bean.Sku{},
			&bean.Transfee{},
			&bean.TransfeeFree{},
			&bean.Transport{},
			&bean.IndexImg{},
			&bean.Basket{},
			// 定时任务
			cron.ScheduleJob{},
			cron.ScheduleJobLog{},

			&bean.StoreCategory{},
			//新版商品
			&bean.StoreProduct{},
			&bean.StoreProductAttr{},
			&bean.StoreProductAttrResult{},
			&bean.StoreProductAttrValue{},
			&bean.StoreProductCate{},
			&bean.StoreProductCoupon{},
			&bean.StoreProductDescription{},
			&bean.StoreProductRelation{},
			&bean.StoreProductReply{},
			&bean.StoreProductRule{},
			//发货设置
			&bean.ShippingTemplates{},
			&bean.ShippingTemplatesFree{},
			&bean.ShippingTemplatesRegion{},
			&bean.ShippingTemplatesNoDelivery{},
		)
		return err
	}
	return err
}
